Skip to content

perf(replay): Use RGB_565 when alpha is unnecessary - #5821

Merged
romtsn merged 9 commits into
mainfrom
rz/perf/use-rgb565-for-replay
Jul 30, 2026
Merged

perf(replay): Use RGB_565 when alpha is unnecessary#5821
romtsn merged 9 commits into
mainfrom
rz/perf/use-rgb565-for-replay

Conversation

@romtsn

@romtsn romtsn commented Jul 22, 2026

Copy link
Copy Markdown
Member

📜 Description

Use RGB_565 for replay recording bitmaps when alpha is unnecessary. PixelCopy keeps
ARGB_8888 when SurfaceView capture is enabled because compositing depends on the transparent
holes left in the Window capture. Canvas capture always uses RGB_565 because it does not support
SurfaceView compositing.

💡 Motivation and Context

RGB_565 halves the recording bitmap's memory footprint. The previous switch to ARGB_8888 was
based on an unconfirmed theory about native bitmap crashes; #5808 instead addresses the concurrent
PixelCopy access and recycling that can produce those crashes.

Fixes #5853

💚 How did you test it?

  • ./gradlew ':sentry-android-replay:testDebugUnitTest' --tests='*PixelCopyStrategyTest*' --info
  • ./gradlew spotlessApply apiDump

Added assertions that regular PixelCopy capture uses RGB_565 and SurfaceView capture retains
ARGB_8888.

Pixel 2XL replay: https://sentry-sdks.sentry.io/explore/replays/626de797788a47ada6bd4c1372c67a5f
HMD Pulse replay: https://sentry-sdks.sentry.io/explore/replays/133aab4923714042b7d3b679fe59c8bf/
Screenshot attached to an event: https://sentry-sdks.sentry.io/issues/7603602409/events/ed83e9c4eb2f452e9d41475339c3a11d

Also tested that SurfaceViews capture still works independently.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

None.

@sentry

sentry Bot commented Jul 22, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.51.0 (1) release

⚙️ sentry-android Build Distribution Settings

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 309.74 ms 359.67 ms 49.93 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
6b019b7 343.31 ms 417.23 ms 73.91 ms
d15471f 342.08 ms 415.44 ms 73.35 ms
8687935 332.52 ms 362.23 ms 29.71 ms
5b1a06b 352.27 ms 413.70 ms 61.43 ms
91bb874 314.47 ms 440.00 ms 125.53 ms
0ee65e9 321.06 ms 361.24 ms 40.18 ms
e63ad34 323.67 ms 390.33 ms 66.67 ms
33a08cc 267.08 ms 340.45 ms 73.37 ms
27d7cf8 397.90 ms 498.65 ms 100.75 ms
ee747ae 405.43 ms 485.70 ms 80.28 ms

App size

Revision Plain With Sentry Diff
6b019b7 0 B 0 B 0 B
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
8687935 1.58 MiB 2.19 MiB 619.17 KiB
5b1a06b 0 B 0 B 0 B
91bb874 1.58 MiB 2.13 MiB 559.07 KiB
0ee65e9 0 B 0 B 0 B
e63ad34 0 B 0 B 0 B
33a08cc 1.58 MiB 2.12 MiB 555.28 KiB
27d7cf8 1.58 MiB 2.12 MiB 549.42 KiB
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB

Previous results on branch: rz/perf/use-rgb565-for-replay

Startup times

Revision Plain With Sentry Diff
31e7057 317.82 ms 364.96 ms 47.14 ms
f2fe68a 321.57 ms 366.41 ms 44.84 ms
850fe59 314.02 ms 351.60 ms 37.58 ms
51b6faf 327.98 ms 377.96 ms 49.98 ms

App size

Revision Plain With Sentry Diff
31e7057 0 B 0 B 0 B
f2fe68a 0 B 0 B 0 B
850fe59 0 B 0 B 0 B
51b6faf 0 B 0 B 0 B

@romtsn
romtsn force-pushed the rz/fix/pixelcopy-frame-race branch 2 times, most recently from fb275d7 to 63eb6f1 Compare July 24, 2026 15:16
Base automatically changed from rz/fix/pixelcopy-frame-race to main July 24, 2026 15:36
@romtsn
romtsn force-pushed the rz/perf/use-rgb565-for-replay branch from 8125299 to f7c7bc0 Compare July 30, 2026 10:00
romtsn and others added 5 commits July 30, 2026 16:06
Keep PixelCopy, masking, compositing, and cleanup from accessing the shared bitmap concurrently.

Fixes GH-5340

Co-Authored-By: Codex <noreply@openai.com>
Re-arm the recorder's content-change gate when a capture is skipped because another frame is still in flight. This ensures the latest UI state is retried on the next capture interval.

Refs GH-5340
Co-Authored-By: OpenAI Codex <noreply@openai.com>
Reduce replay screenshot memory while retaining ARGB_8888 for SurfaceView compositing.

Refs GH-5340
Co-Authored-By: Codex <noreply@openai.com>
Screen content is always opaque so the alpha channel in ARGB_8888 is wasted.
RGB_565 halves the per-screenshot bitmap memory (~2B/px vs 4B/px).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@romtsn
romtsn force-pushed the rz/perf/use-rgb565-for-replay branch from 30ecbc9 to 3dfd8f9 Compare July 30, 2026 14:06
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@romtsn
romtsn marked this pull request as ready for review July 30, 2026 14:08
@romtsn romtsn added the ship-it PR is ready to merge from a reviewer perspective label Jul 30, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@runningcode runningcode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

romtsn and others added 2 commits July 30, 2026 16:44
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@romtsn
romtsn enabled auto-merge (squash) July 30, 2026 14:52
@romtsn
romtsn merged commit 5cb2c36 into main Jul 30, 2026
69 of 72 checks passed
@romtsn
romtsn deleted the rz/perf/use-rgb565-for-replay branch July 30, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ship-it PR is ready to merge from a reviewer perspective

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate using alternative Bitmap formats (e.g. RGB_565) to reduce memory footprint

3 participants